<!--
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
*
 ********************************************************************************/
-->
<div id="action">
	<div class="left">
      <span class='lvtHeaderText'><?php echo getTranslatedString('LBL_KNOWLEDGE_BASE');?></span>	
   </div>
   <div class="right">
      <form name="Submit" method="post" action="index.php">
      	<input type="hidden" name="fun" value="search" />
      	<input type="hidden" name="module" value="Faq" />
      	<input type="hidden" name="action" value="index" />
      	<input type="text" name="search_text" value="<?php echo $search_text; ?>" /> in
      	<?php echo getSearchCombo(); ?>
      	<input class="crmbutton small cancel" type="submit" name="search" onclick="form.fun.value='search'" value="<?php echo getTranslatedString('LBL_SEARCH'); ?>" />
      </form>   
   </div>
</div><!-- End action -->
<div id="faq">
   <?php if(!empty($faq_array)){ ?>
   <div id="navArea">
      <div class="catMnu">
      	<?php if((count($category_array))>0 && $category_array !=null){ ?>
      	   <span class="hdr">
      		   <a href="javascript:;toggleView('category_array')">
      		      <img id="categoryimg" src="images/minus.gif" alt="minus image" />
      		   </a>
      	      <a href="javascript:;toggleView('category_array')">
      	         <img src="images/category.gif" alt="product image" />
      	      </a>
      	      <a href="javascript:;toggleView('category_array')" class="kbNavHead">
      	         <?php echo getTranslatedString('LNK_CATEGORY'); ?>
      	      </a>
   	      </span>
   		   <div id="category_array" style="display:block">
   				<?php
   				   for($i=0,$j=1;$i<count($category_array);$i++,$j++){
   	        			$noof_faqs = getNoofFaqsPerCategory($category_array[$i]);
   						if(is_string($_REQUEST['category_index'])){
   							$category_index = (int)$_REQUEST['category_index'];
   					}
   				?>
   				<span class="item">
      			   <a href="index.php?module=Faq&amp;action=index&amp;fun=faqs&amp;category_index=<?php echo $i; ?>">
      					<?php if($category_index === $i)
      					   echo '<b>'.text_length($category_array[$i]).'</b>'; 
      					else
      						echo text_length($category_array[$i]);
      					?>
      				</a>
      				<?php if($category_index === $i) 
      				   echo '<b>'.'('.$noof_faqs.')'.'</b>'; 
      				else
      					echo '('.$noof_faqs.')';
      				?>
   				</span>
   			</div>
         <?php } ?>
      </div><!-- End catMnu -->
   <?php } ?>
   <?php if($product_array != null) { ?>
      <div id="prodMnu">
         <span class="hdr">
            <a href="javascript:;toggleView('products_array')">
               <img id="products_arrayimg" src="images/minus.gif" alt="minus-image" />
            </a>
         	<a href="javascript:;toggleView('products_array')">
         	   <img src="images/products.gif" alt="products image" />
         	</a>
         	<a href="javascript:;toggleView('products_array')" class="kbNavHead"><?php echo getTranslatedString('LNK_PRODUCTS'); ?></a>
      	</span>
      	<div id="products_array">
      		<?php for($i=0,$j=1;$i<count($product_array);$i++,$j++) {
      		   $noof_faqs = getNoofFaqsPerProduct($product_array[$i]['productid']);	?>
      		      <span class="item">
         		      <a href="index.php?module=Faq&amp;action=index&amp;fun=faqs&amp;productid=<?php echo $product_array[$i]['productid']; ?>">
         		         <?php	if($_REQUEST['productid'] == $product_array[$i]['productid']) 
         					   echo '<b>'.$product_array[$i]['productname'].'</b>'; 
         				   else
         					   echo $product_array[$i]['productname'];
         					?>
         				</a>
         					<?php	if($_REQUEST['productid'] == $product_array[$i]['productid']) 
         					   echo '<b>'.'('.$noof_faqs.')'.'</b>'; 
         				   else 
         					   echo '('.$noof_faqs.')';
         		         ?>
      		      </span>
      		<?php } ?>
      	</div>
      </div><!-- End prodMnu -->
   </div><!-- End navArea -->
   <?php	} ?>
   <?php } else { ?>
      <?php echo getTranslatedString('LBL_KNOWLEDGE_BASE').' '.getTranslatedString('LBL_NOT_AVAILABLE');?>
   <?php } ?>
   <script language="JavaScript" src="js/cookies.js"></script>
   <script type="text/javascript">
   function toggleView(view) {
   	if(document.getElementById(view) != null){
   		if (document.getElementById(view).style.display=="block") {
   			document.getElementById(view).style.display="none"
   			document.getElementById(view+"img").src="images/plus.gif"
   			set_cookie("kb_"+view,"none")
   		} else {
   			document.getElementById(view).style.display="block"
   			document.getElementById(view+"img").src="images/minus.gif"
   			set_cookie("kb_"+view,"block")
   		}
   	}
   }
   
   var view=new Array("category","products_array")
   for (i=0;i<view.length;i++) {
   	if(document.getElementById(view) != null){
   		if (get_cookie("kb_"+view[i])==null || get_cookie("kb_"+view[i])=="" || get_cookie("kb_"+view[i])=="block") {
   			document.getElementById(view[i]).style.display="block"
   			document.getElementById(view[i]+"img").src="images/minus.gif"
   		} else {
   			document.getElementById(view[i]).style.display="none"
   			document.getElementById(view[i]+"img").src="images/plus.gif"
   		}
   	}
   }
   </script>